package com.poetry.controller.user;

import com.poetry.domain.po.History;
import com.poetry.exception.R;
import com.poetry.service.IHistoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController("/history")
@Tag(name = "浏览历史管理模块")
public class HistoryController {
    @Resource
    private IHistoryService historyService;

    @Operation(summary = "添加历史记录")
    @PostMapping("/add_history")
    public R<String> addHistory(@RequestParam Integer id) {
        return historyService.addHistory(id);
    }

    @GetMapping("/get_histories")
    @Operation(summary = "查询浏览记录")
    public R<List<History>> queryHistory(@RequestParam(defaultValue = "10") Integer limit) {
        return historyService.queryHistory(limit);
    }

    @Operation(summary = "清空历史记录")
    @DeleteMapping("/clear")
    public R<String> clearHistory() {
        return historyService.clearHistory();
    }
}
